#! /bin/sh

if test -d ../fw/bin
  then
    PATH="`pwd`/../fw/bin:$PATH"
    export PATH
  fi

if test -z "$MAKE"
  then
    gmake=`which gmake`

    if test $? = 0 
      then
        MAKE=gmake
      else
        MAKE=make
      fi
  fi

(
set -x
test -h share || ln -sf .. share || exit 1
rm -rf tmp 
FW_ROOT=`pwd`
export FW_ROOT
fw-init --name tmp                              \
        --revision none                         \
        --template "__TEMPLATE_TYPE__"          || exit 1
cd tmp
./bootstrap || exit 1
./build || exit 1
"${MAKE}" -s check || exit 1
"${MAKE}" -s maintainer-clean
test -z "`find . -name '*.am'`" || exit 1
) > test-template.out 2>&1 || exit 1

rm share || exit 1
rm -rf tmp || exit 1
